/*
 * @Author: egg1bro
 * @Date: 2023-01-07 23:24:23
 * @LastEditTime: 2023-01-08 12:03:42
 * @LastEditors: egg1bro
 * @Description: 
 * @FilePath: \team-graduation-design\src\stores\register.js
 * 可以输入预定的版权声明、个性签名、空行等
 */
import { defineStore } from 'pinia'
import { reqRegisterUser, reqAddUserName } from '@/api/index'
import router from '@/router/index'

export const useRegisterStore = defineStore('register', () => {

    // 注册接口
    const getRegisterUser = async (params = {}) => {
        let result = await reqRegisterUser(params)
        if (result.code == 200) {
            console.log(result.msg);
            router.push({ path: '/addName', query: { user_phone: params.user_phone } })
        } else {
            console.log(result.msg);
        }
    }

    // 添加用户姓名接口
    const getAddUserName = async (params = {}) => {
        let result = await reqAddUserName(params)
        if (result.code == 200) {
            console.log(result.msg);
            router.push('/login')
        } else {
            console.log(result.msg);
        }
    }
    return { getRegisterUser, getAddUserName }

})